package com.ewanghuiju.app.presenter.my;

import com.ewanghuiju.app.base.RxPresenter;
import com.ewanghuiju.app.base.contract.my.FansInfoContract;
import com.ewanghuiju.app.model.DataManager;
import com.ewanghuiju.app.model.bean.response.TeamInfoResponBean;
import com.ewanghuiju.app.model.http.response.Optional;
import com.ewanghuiju.app.util.RxUtil;
import com.ewanghuiju.app.widget.CommonSubscriber;

import javax.inject.Inject;

/**
 * @author sj  qq:751943509
 * @class 我的团队
 * @time 2020/2/16
 */
public class FansInfoPresenter extends RxPresenter<FansInfoContract.View> implements FansInfoContract.Presenter {

    private DataManager mDataManager;

    @Inject
    public FansInfoPresenter(DataManager mDataManager) {
        this.mDataManager = mDataManager;
    }

    @Override
    public void getData(int page, String search, String id) {
        addSubscribe(mDataManager.getMyfansinfo(page, search, id)
                .compose(RxUtil.rxSchedulerHelper())
                .compose(RxUtil.handleMyResultCannull())
                .subscribeWith(new CommonSubscriber<Optional<TeamInfoResponBean>>(mView) {
                    @Override
                    public void onNext(Optional<TeamInfoResponBean> optional) {
                        if (mView != null)
                            mView.showContent(optional.getIncludeNull());
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        if (mView != null)
                            mView.showContentError();
                    }
                })
        );
    }
}
